package com.twu.biblioteca;

/**
 * Created by xndong on 10/4/14.
 */
public class Movie {
    public long MovieId;
    public String Name;
    public int Year;
    public int MovieRating;
    public String Director;
    public boolean IsCheckOut;

    private static int Count=0;
    private String LastUser;

    public Movie(String name, int year, int rating, String director, boolean isCheckOut) {
        Name = name;
        Year = year;
        MovieRating = rating;
        Director = director;
        IsCheckOut = isCheckOut;
        MovieId = Id();
    }

    private long Id() {return ++Count;}

    public void CheckOut(String custom){
        if (this.IsCheckOut) Show.Message("That movie is not available.");
        this.IsCheckOut = true;
        LastUser = custom;
        Show.Message("Thank you! Enjoy the movie.");
    }

    public void Return(String custom){
        if (!this.IsCheckOut) Show.Message("That is not a valid movie to return.");
        if (!custom.equals(LastUser))  Show.Message("Action is forbidden");
        this.IsCheckOut = false;
        Show.Message("Thank you for returning the movie.");
    }
}
